package top.limitblog.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import top.limitblog.pojo.UsersEntity;
import top.limitblog.service.LoginService;

import javax.annotation.Resource;

/**
 * Created by liuyu on 15/10/2016.
 */
@Controller
@RequestMapping("/")
public class LoginController {
    @Resource
    private LoginService loginService;

    @RequestMapping("/login.html")
    public String showUserList(UsersEntity user) {

        if (!user.getName().equals("") && user.getName() != null) {
            if (!user.getPassword().equals("") && user.getPassword() != null) {
                UsersEntity currentUser = loginService.find(user);
                if (null != currentUser) {
                    return "success";
                }
            }
        }
        return "error";
    }

}
